import { request } from '@utils/http';
import { Key } from 'react';

import type {
    getHosSetListParamsType,
    getHosSetListReturnType,
    addHospitalParamsType,
    getHosSetListItemType,
    updateHospitalParamsType
} from './model/hospitalSetTypes'
//获取医院设置的列表请求。参数为配置对象，没有page（页数），limit（数据的总数），hosname（医院名称），hoscode（医院编号）
export const getHosSetListRequest = ({ page, limit, hosname, hoscode }: getHosSetListParamsType) => {
    return request.get<any, getHosSetListReturnType>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
        params: {
            hosname,
            hoscode
        }
    })
}

//添加医院数据的请求，参数为一个请求体对象
export const addHospitalRequest = (data: addHospitalParamsType) => {
    return request.post<any, null>('/admin/hosp/hospitalSet/save', data)
}

//更新的时候获取医院数据的请求，参数为id
export const getHosSetFormIdRequest=(id:string)=>{
    return request.get<any,getHosSetListItemType>(`/admin/hosp/hospitalSet/get/${id}`)
}

//更新数据的请求，参数为body
export const updateHosSetRequest=(data:updateHospitalParamsType)=>{
    return request.put<any,null>('/admin/hosp/hospitalSet/update',data)
}

//删除医院数据的请求，参数为路径
export const deleteHosListRequest = (id:number) => {
    return request.delete<any,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

//批量删除医院数据的请求，参数为id组成的数组

export const batchRemoveHosListRequest=(ids:Key[])=>{
    return request.delete<any,null>('/admin/hosp/hospitalSet/batchRemove',{
        data:ids
    })
}



